package com.example.module_word.adapter

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.blankj.utilcode.util.LogUtils
import com.example.module_word.R
import com.example.module_word.dialog.SelectLanGuageAdapter
import com.fenghuajueli.`interface`.LanguageClickListener
import com.jin_mo.custom.adapter.find_id.RVBaseAdapter
import com.jin_mo.custom.adapter.find_id.RVBaseViewHolder
/**
 * @ProjectName: ModuleDev
 * @Package: com.fenghuajueli.adapter
 * @Description: 翻译语言选择
 * @Author: sz_ijj
 * @CreateDate: 2022/3/3 11:49
 * @UpdateUser: 更新者
 * @UpdateDate: 2022/3/3
 * @UpdateRemark: 更新说明
 */
class DialogLanguageAdapter : RVBaseAdapter<Pair<String, MutableList<Triple<String, String, Int>>>>() {

    private lateinit var languageAdapter: SelectLanGuageAdapter

    private var languageClickListener: LanguageClickListener? = null


    override fun bindLayoutId(): Int {
        return R.layout.adapter_dialog_languange
    }

    override fun convert(holder: RVBaseViewHolder, mList: MutableList<Pair<String, MutableList<Triple<String, String, Int>>>>, t: Pair<String, MutableList<Triple<String, String, Int>>>, position: Int) {
        holder.setText(R.id.tv_adapter_dialog_desc, t.first)
        languageAdapter = SelectLanGuageAdapter()
        languageAdapter.refreshData(t.second)
        LogUtils.json(t.first, t.second)

        with(holder.getItemView().findViewById<RecyclerView>(R.id.rv_adapter_dialog_language)) {
            layoutManager = LinearLayoutManager(context)
            adapter = languageAdapter
        }

        languageAdapter.setOnItemClick { adapter, view, language, i ->
            languageClickListener?.let {
                it.click(language.first, language.second)
            }
        }
    }

    fun setClickListener(clickListener: LanguageClickListener) {
        this.languageClickListener = clickListener
    }

    override fun convert(holder: RVBaseViewHolder) {

    }
}